package mvc.command.update
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.hexagonstar.util.debug.Debug;

	import flash.net.SharedObject;

	import mx.collections.ArrayCollection;

	import nz.co.codec.flexorm.EntityManager;

	import orm.fantasy.RCharItemVO;
	import orm.fantasy.TblCharacterVO;

	public class BackupUserDBCmd implements ICommand
	{
		private var _em:EntityManager;

		public function execute(event:CairngormEvent):void
		{
			_em = EntityManager.instance;
			var characters:ArrayCollection = _em.findAll(TblCharacterVO);
			var rCharItems:ArrayCollection = _em.findAll(RCharItemVO);

			var so:SharedObject = SharedObject.getLocal("WowFantasy");
			so.data.cache = true;
			so.data.characters = characters;
			so.data.rCharItems = rCharItems;
			Debug.trace("set characters = " + characters.length + ", rCharItems = " + rCharItems.length);
			so.flush();
		}
	}
}